// view/index/jk/shenqjl/shenqjl.js
let app = getApp()
let yuming = app.globalData.yuming
var shuzong = []
var shu = []
const request = require('../../config/request');
Page({
  /**
   * 页面的初始数据
   */
  ...request,
  data: {
    yuming: yuming,
    heights: "",
    title: '申请记录',
    jian: [],
    page: 1,
    gongwu: false,
  },
  // 查看更多
  lookmore() {
    shuzong = this.data.jian
    this.setData({
      page: (this.data.page) + 1
    })
    this.getsqjlList();
  },
  getsqjlList() {
    let that = this;
    wx.showLoading({
      title: '加载中',
      icon: 'none'
    })
    this.myRequest(yuming + 'Monitor/shop_monitoring_list', {
      shopId: wx.getStorageSync('shopId'),
      page: that.data.page
    }, 'POST').then(res => {
      wx.hideLoading();
      if (res.data.code == 200) {
        shu = res.data.data
        shu.forEach(item => {
          if (item.endTime != null) {
            item.endtime = this.formatDate(new Date(item.endTime * 1000))
          }
        })
        if (this.data.page != 1) {
          if (shu.length != 10) {
            wx.showToast({
              title: '没有更多数据了~',
              icon: "none"
            })
            this.setData({
              gongwu: true
            })
          }
        }
        this.setData({
          jian: shuzong.concat(shu)
        })
      }
    })
  },
  formatTen: function (num) {
    return num > 9 ? (num + "") : ("0" + num);
  },
  formatDate: function (date) {
    var year = date.getFullYear();
    var month = date.getMonth() + 1;
    var day = date.getDate();
    return year + "-" + this.formatTen(month) + "-" + this.formatTen(day);
  },
  backs() {
    wx.navigateBack({
      delta: 0
    })
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    this.setData({
      heights: wx.getMenuButtonBoundingClientRect().top + 5
    })
    shuzong = []
    shu = []
    this.getsqjlList();
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },
})